# -*- coding: UTF-8 -*-
from sqlalchemy import Column, Integer, String, DateTime, Boolean, text, JSON
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime

Base = declarative_base()


class PrizeResult(Base):
    __tablename__ = 'frontapp_prize_result'
    __table_args__ = {'extend_existing': True}
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键id')
    openid = Column(String(255), nullable=False, comment='用户openid')
    phone = Column(String(255), nullable=True, comment='手机号')
    dealerCode = Column(String(255), nullable=True, comment='经销商id')
    prize_name = Column(String(255), nullable=True, comment='奖品名称')
    check_code = Column(String(255))
    state = Column(Integer, nullable=False, comment='1中奖0未中奖2答题')
    vx_card = Column(JSON, server_default=text("'{}'"), comment='json数据')
    create_time = Column(DateTime, nullable=False, comment='创建时间')


class SubmitClue(Base):
    __tablename__ = 'frontapp_submit_clue'
    __table_args__ = {'extend_existing': True}
    id = Column(Integer, primary_key=True, autoincrement=True)
    openid = Column(String(255), unique=True, index=True)
    phone = Column(String(255), nullable=True)
    name = Column(String(255), nullable=True)
    dealerId = Column(String(255), nullable=True)
    seriesId = Column(Integer, nullable=True)
    create_time = Column(DateTime, default=datetime.now)


class WinningGen(Base):
    __tablename__ = 'frontapp_winning_gen'
    __table_args__ = {'extend_existing': True}
    id = Column(Integer, primary_key=True, autoincrement=True)
    openid = Column(String(255), unique=True, index=True)
    phone = Column(String(255), nullable=True)
    name = Column(String(255), nullable=True)
    address = Column(String(255), nullable=True)
    check_code = Column(String(255), nullable=True)
    create_time = Column(DateTime, default=datetime.now)
